package com.qf.ssm.mapper;

import com.qf.ssm.pojo.Devices;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface DevicesMapper {

    void addDevices(Devices devices);

    int updateDevices(Devices devices);

    int deleteDevicesByIds(@Param("ids") List <Long> ids);

    List<Devices> getAllDevices(@Param("address")String address,@Param("status") int status, @Param("direction") int direction, @Param("areaid") int areaid,@Param("categoryid") int categoryid);


    @Select("SELECT categoryid FROM devices WHERE devicesuuid=#{uuid}")
    Long getCategoryIdByUUID(String  uuid);

    @Select("SELECT * FROM devices WHERE d.id = #{id}")
    Devices getDeviceById(Long id);

    @Select("SELECT * FROM devices devicesuuid =#{devicesuuid}")
    Devices getDeviceByUUId(String uuid);

    @Update("UPDATE devices SET  status =#{status}  WHERE devicesuuid = #{uuid}")
    void updateOffLine(@Param("uuid") String uuid,@Param("status") String status);
}
